#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
void move(char* a, char* b)
{
	printf("%s->%s\n",a,b);
}
void hanoi(char* a, char* b, char* c, int n)
{
	if (n == 1)
	{
		move(a, c);
	}
	else
	{
		hanoi(a, c, b, n - 1);
		move(a, c);
		hanoi(b, a, c, n - 1);
	}
}
int main()
{
	int n;
	scanf("%d", &n);
	getchar();
	char a[10] = { 0 };
	char b[10] = { 0 };
	char c[10] = { 0 };
	gets(a);
	gets(b);
	gets(c);
	
	hanoi(a,b,c,n);
	return 0;
}
